import java.util.Arrays;

/**
 * @author hewei
 * @version 1.0
 * @description: 周赛308 t1
 * @date 2022/8/28 10:32
 */

public class AnswerQueries {

    public int[] answerQueries(int[] nums, int[] queries) {
        Arrays.sort(nums);
        int[] ans = new int[queries.length];
        for (int i = 0; i < queries.length; i++) {
            int target = queries[i];
            int sum = 0;
            for (int j = 0; j < nums.length; j++) {
                sum += nums[j];
                if (sum > target) {
                    ans[i] = j;
                    break;
                }
                if (j == nums.length - 1) ans[i] = j + 1;
            }
        }
        return ans;
    }
}
